home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / text / edit / tecoc-146.lha / exeequ.c < prev    next >
C/C++ Source or Header  |  1991-07-05  |  2KB  |  69 lines

  1. /*****************************************************************************
  2.  
  3.     ExeEqu()
  4.  
  5.     This function executes the = (equals sign) command:
  6.  
  7.     n=    display n in decimal,  with carriage return
  8.     n==    display n in octal,  with carriage return
  9.     n===    display n in hexadecimal,  with carriage return
  10.     n:=    display n in decimal,  without carriage return
  11.     n:==    display n in octal,  without carriage return
  12.     n:===    display n in hexadecimal,  without carriage return
  13.  
  14. *****************************************************************************/
  15.  
  16. #include "zport.h"        /* define portability identifiers */
  17. #include "tecoc.h"        /* define general identifiers */
  18. #include "defext.h"        /* define external global variables */
  19. #include "dchars.h"        /* define identifiers for characters */
  20. #include "deferr.h"        /* define identifiers for error messages */
  21.  
  22. DEFAULT ExeEqu()        /* execute an = (equals sign) comand */
  23. {
  24.     DBGFEN(1,"ExeEqu",NULL);
  25.  
  26.     if (EStTop == EStBot) {            /* if no numeric argument */
  27.         ErrMsg(ERR_NAE);        /* NAE = "No arg before =" */
  28.         DBGFEX(1,DbgFNm,"FAILURE, no arg before =");
  29.         return FAILURE;
  30.     }
  31.  
  32.     if (GetNmA() == FAILURE) {        /* get the numeric argument */
  33.         DBGFEX(1,DbgFNm,"FAILURE, GetNmA() failed");
  34.         return FAILURE;
  35.     }
  36.  
  37.     if (*(CBfPtr+1) != '=') {        /* if next char not = */
  38.         MakDBf(NArgmt, 10);        /* make string in decimal */
  39.     } else {
  40.         if (IncCBP() == FAILURE) {    /* move to next char */
  41.             DBGFEX(1,DbgFNm,"FAILURE");
  42.             return FAILURE;
  43.         }
  44.  
  45.         if (*(CBfPtr+1) != '=') {    /* if next char not = */
  46.             MakDBf(NArgmt, 8);    /* make string in octal */
  47.         } else {
  48.             if (IncCBP() == FAILURE) { /* move to next char */
  49.                 DBGFEX(1,DbgFNm,"FAILURE");
  50.                 return FAILURE;
  51.             }
  52.             MakDBf(NArgmt, 16);    /* make string in hex */
  53.         }
  54.     }
  55.  
  56.     if (CmdMod & COLON) {            /* if colon modified */
  57.         CmdMod &= ~COLON;        /* clear colon flag */
  58.     } else {
  59.         *DBfPtr++ = CRETRN;        /* append a carriage return */
  60.         *DBfPtr++ = LINEFD;        /* append a line feed */
  61.     }
  62.  
  63.     ZDspBf(DBfBeg, DBfPtr-DBfBeg);        /* display the string */
  64.  
  65.     DBGFEX(1,DbgFNm,"SUCCESS");
  66.  
  67.     return SUCCESS;
  68. }
  69.